package com.miaoshare.app;


import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.miaoshare.app.mvp.model.UserInfoEntity;
import com.miaoshare.app.mvp.presenter.MainPresenter;
import com.miaoshare.app.mvp.view.MainView;
import com.miaoshare.core.base.BaseActivity;
import com.miaoshare.core.utils.LogUtil;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.OnClick;
import timber.log.Timber;

public class MainActivity extends BaseActivity<MainPresenter> implements MainView {


    @BindView(R.id.tv_login)
    TextView tvLogin;
    @Override
    protected boolean isRegisterEventBus() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void loadData() {

    }

    @Nullable
    @Override
    protected MainPresenter initPresenter() {
        return new MainPresenter();
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onServiceEvent(ServiceEvent event) {
        Log.e("1111", "111111 收到事件");
    }

    public void sss() {
//        Api.get().urls()
//                .compose(new ErrorTransform<>())
//                .compose(new ProgressDialogTransform<>(this))
//                .subscribe(new Action1<String>() {
//                    @Override
//                    public void call(String json) {
//                        Log.e("11111", json);
//
//                    }
//                })
//        ;
    }


    public void onClick11() {
        Timber.e("dengl");

//        Api.get().login("1", "1", "1", "", "", "")
//                .compose(new ErrorTransform())
//                .compose(new ProgressDialogTransform<>(this))
//                .subscribe(new Action1<String>() {
//                    @Override
//                    public void call(String json) {
//                        Timber.e("login" + json);
//                    }
//                });
    }

    @OnClick({R.id.tv_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_login:
                presenter.login("JakeWharton","1234");
                break;
        }
    }

    @Override
    public void loginSuccess(int code, UserInfoEntity data) {
        LogUtil.e("登录成功"+data.getName());

    }

    @Override
    public void onLoginError(String message) {

    }
}